/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package conversation;

import example.model.Database;
import example.model.Person;
import example.model.PersonMapper;

import org.jmock.Mock;
import org.jmock.MockObjectTestCase;

public class JMockExample extends MockObjectTestCase {
	private Mock mockDatabase;
	private PersonMapper personMapper;

	@Override
	protected void setUp() throws Exception {
		mockDatabase = mock(Database.class);
		personMapper = new PersonMapper((Database) mockDatabase.proxy());
	}

	public void testPersonMapperShouldUseDatabaseToSaveAPerson() {
		mockDatabase.expects(once())
			.method("insert")
			.with(eq("insert into people (name) values('Fred Dibner')"));
//			.will(returnValue(true));

		Person fred = new Person("Fred Dibner");
		personMapper.save(fred);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	public void thing(MockDatabase mockDatabase) {
		mockDatabase.expects("no. occurences").method("method").with("parameter constraints").will("return value");
	}













































































	interface MockDatabase {
		MockDatabase expects(String occurence);
		
		MockDatabase method(String method);
		
		MockDatabase with(String constraints);
		
		MockDatabase will(String returnValue);
	}
	
}
